﻿using DDU.Infrastructure;
using System;
using System.Collections.Generic;
using System.Data.Linq.Mapping;
using System.Linq;
using System.Text;

namespace DDU.DataModel
{
    [Table(Name = "T_ExamCourse")]
    public class ExaminationCourseInfo : NotificationObject
    {
        #region Fields
        private string _guid = System.Guid.NewGuid().ToString();
        private string _examGuid;
        private string _courseName;
        private string _roomOrPlace;
        private string _invigilator;
        private double _fullMark = 100;
        private double _actualMark = 0;
        private DateTime _startTime = DateTime.Now;
        private DateTime _endTime = DateTime.Now.AddMinutes(90);
        #endregion

        #region Properties
        [Column(IsPrimaryKey = true)]
        public string Guid
        {
            get { return _guid; }
            set
            {
                _guid = value;
                RaisePropertyChanged(() => Guid);
            }
        }

        [Column]
        public string ExamGuid
        {
            get { return _examGuid; }
            set
            {
                _examGuid = value;
                RaisePropertyChanged(() => ExamGuid);
            }
        }
        
        [Column]
        public string CourseName
        {
            get { return _courseName; }
            set
            {
                _courseName = value;
                RaisePropertyChanged(() => CourseName);
            }
        }

        [Column]
        public string RoomOrPlace
        {
            get { return _roomOrPlace; }
            set
            {
                _roomOrPlace = value;
                RaisePropertyChanged(() => RoomOrPlace);
            }
        }

        [Column]
        public string Invigilator
        {
            get { return _invigilator; }
            set
            {
                _invigilator = value;
                RaisePropertyChanged(() => Invigilator);
            }
        }

        [Column]
        public double FullMark
        {
            get { return _fullMark; }
            set
            {
                _fullMark = value;
                RaisePropertyChanged(() => FullMark);
            }
        }

        [Column]
        public double ActualMark
        {
            get { return _actualMark; }
            set
            {
                _actualMark = value;
                RaisePropertyChanged(() => ActualMark);
            }
        }

        [Column]
        public DateTime StartTime
        {
            get { return _startTime; }
            set
            {
                _startTime = value;
                RaisePropertyChanged(() => StartTime);
            }
        }

        [Column]
        public DateTime EndTime
        {
            get { return _endTime; }
            set
            {
                _endTime = value;
                RaisePropertyChanged(() => EndTime);
            }
        }
        #endregion

        #region Event
        public event EventHandler<PropertyArgs> ValueChanged = delegate { };

        protected override void RaisePropertyChanged(string propertyName)
        {
            base.RaisePropertyChanged(propertyName);
            ValueChanged.Invoke(this, new PropertyArgs()
            {
                Property = GetType().GetProperty(propertyName)
            });
        }
        #endregion
    }
}
